﻿//===============================================================================
// Magic OQL
//===============================================================================
// Copyright ?Magic Thought Corporation. All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// Richie (http://www.cnblogs.com/RicCC)
// March 8, 2008
//===============================================================================

using Antlr.Runtime;

namespace SQLAnalyticLibrary.Expressions
{
    /// <summary>
    /// </summary>
    public class Having : Expression
    {
        public Having(IToken t)
            : base(t)
        {
        }
        public Having(Having t)
            : base(t.Token)
        {
            this._children = t._children;
        }
        public override Expression DupNode()
        {
            return new Having(this);
        }
        public static bool IsHaving(Expression exp)
        {
            if (exp == null || exp.IsNil) return false;
            return exp.Token.Type == OQLParser.HAVING;
        }
        public override void VisitSql(ISqlVisitor visitor)
        {
            visitor.Sql(this.ToString()); //HAVING keyword
            visitor.Space();
            this.InternalVisitSql(visitor, false, null); //items of HAVING
        }
    }
}
